#include <stdio.h>
#include <string.h>
#include <math.h>

int isExpTimeTag( char *str ){
    char *ptr = strchr(str, 'd');
    
    int res = -1;
    if( NULL != ptr )
        res = 1;
    else
        res = 0;
        
    return res;
}

double extractExpTime( char *str ){

    int str_len = strlen(str);
    char *ptr_d = strchr(str, 'd');
    int idx_d = ptr_d - str;
    
    int i = 0;
    int exp_t_int = 0;      // integer part
    double exp_t_dec = 0;   // decimal part
    
    while( i < str_len ){
        printf(" I = %3d\n", i);
        
        if( i < idx_d ){
            exp_t_int += (str[i]-'0')*pow(10, idx_d - i -1);
        }
        
        if( i > idx_d ){
            exp_t_dec += (str[i]-'0')*pow(10, idx_d - i);
        }
        
        i++;
    }
    double exp_t = exp_t_int + exp_t_dec;

    return exp_t;
}



int main( int argc, char *argv[] ){
    
/*    char tag[] = "1234d567";*/

    char tag[128];
    sprintf(tag, "%s", argv[1]);

    double exp_t = -1;
    
    if( isExpTimeTag(tag) ){
        exp_t = extractExpTime(tag);
    }
    
    printf("exp_t = %10.5f\n", exp_t);
    
    return 0;
}
